]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Bug 589937 - Raise clone on window activation
authorColin Walters <walters@verbum.org>
Fri, 31 Jul 2009 21:20:26 +0000 (17:20 -0400)
committerColin Walters <walters@verbum.org>
Fri, 31 Jul 2009 23:26:32 +0000 (19:26 -0400)
We had duplicate code in appDisplay and workspaces for handling activating
a window; unify that inside workspaces, add an API to Main.overlay to
access it from both contexts.

Also, explicitly raise the clone we're activating to the top
before starting the animation to leave the overlay.

js/ui/appDisplay.js
js/ui/overlay.js
js/ui/workspaces.js

index 9ecfc116b11837a5ef19bfc53e4a9dddd1edcbce..7025e4e769f635584190ae6e2ba1ab6c48dc2e5d 100644 (file)
@@ -14,6 +14,7 @@ const Mainloop = imports.mainloop;
 
 const DND = imports.ui.dnd;
 const GenericDisplay = imports.ui.genericDisplay;
+const Main = imports.ui.main;
 const Workspaces = imports.ui.workspaces;
 
 const ENTERED_MENU_COLOR = new Clutter.Color();
@@ -527,17 +528,10 @@ WellDisplayItem.prototype = {
         if (this._windows.length == 0)
             this.launch();
         else {
-            /* Pick the first window and activate it, switching to its workspace
-             * if necessary.  In the future, we want to have a menu dropdown here. */
+            /* Pick the first window and activate it;
+             * In the future, we want to have a menu dropdown here. */
             let first = this._windows[0];
-            let firstWorkspace = first.get_workspace();
-            let currentWorkspaceIndex = Shell.Global.get().screen.get_active_workspace_index();
-            let currentWorkspace = Shell.Global.get().screen.get_workspace_by_index(currentWorkspaceIndex);
-            let ts = Clutter.get_current_event_time();
-            if (currentWorkspace != firstWorkspace)
-                firstWorkspace.activate_with_focus(first, ts);
-            else
-                first.activate(ts);
+            Main.overlay.activateWindow (first, Clutter.get_current_event_time());
         }
         this.emit('activated');
     },
index f0ea2e770d3865aed41fb5f0922c742cb930eb00..235b0ee0f06ccd313a1ae2b431cb213281a197a0 100644 (file)
@@ -934,6 +934,21 @@ Overlay.prototype = {
             this.show();
     },
 
+    /**
+     * activateWindow:
+     * @metaWindow: A #MetaWindow
+     * @time: Event timestamp integer
+     *
+     * Make the given MetaWindow be the focus window, switching
+     * to the workspace it's on if necessary.  This function
+     * should only be used when the overlay is currently active;
+     * outside of that, use the relevant methods on MetaDisplay.
+     */
+    activateWindow: function (metaWindow, time) {
+         this._workspaces.activateWindowFromOverlay(metaWindow, time);
+         this.hide();
+    },
+
     //// Private methods ////
 
     // Raises the Dash to the top, so that we can tell if the pointer is above one of its items.
index e70329456f8d05f050e73ce568856f0245df5fcc..7da0e40ec7b969e4fb5a9391fa69c075bfefcbcc 100644 (file)
@@ -364,6 +364,23 @@ Workspace.prototype = {
         }
     },
 
+    _lookupIndexAndClone: function (metaWindow) {
+        let index, clone;
+        for (let i = 0; i < this._windows.length; i++) {
+            if (this._windows[i].metaWindow == metaWindow) {
+                index = i;
+                clone = this._windows[index];
+                return [index, clone];
+            }
+        }
+        return [-1, null];
+    },
+
+    lookupCloneForMetaWindow: function (metaWindow) {
+        let [index, clone] = this._lookupIndexAndClone (metaWindow);
+        return clone;
+    },
+
     _adjustRemoveButton : function() {
         this._removeButton.set_scale(1.0 / this.actor.scale_x,
                                      1.0 / this.actor.scale_y);
@@ -450,14 +467,7 @@ Workspace.prototype = {
         let win = metaWin.get_compositor_private();
 
         // find the position of the window in our list
-        let index = - 1, clone;
-        for (let i = 0; i < this._windows.length; i++) {
-            if (this._windows[i].metaWindow == metaWin) {
-                index = i;
-                clone = this._windows[index];
-                break;
-            }
-        }
+        let [index, clone] = this._lookupIndexAndClone (metaWin);
 
         if (index == -1)
             return;
@@ -712,15 +722,7 @@ Workspace.prototype = {
     },
 
     _onCloneSelected : function (clone, time) {
-        let global = Shell.Global.get();
-        let activeWorkspace = global.screen.get_active_workspace_index();
-
-        if (this.workspaceNum != activeWorkspace) {
-            let workspace = global.screen.get_workspace_by_index(this.workspaceNum);
-            workspace.activate_with_focus(clone.metaWindow, time);
-        } else
-            clone.metaWindow.activate(time);
-        Main.overlay.hide();
+        Main.overlay.activateWindow(clone.metaWindow, time);
     },
 
     _removeSelf : function(actor, event) {
@@ -828,6 +830,32 @@ Workspaces.prototype = {
                                           Lang.bind(this, this._activeWorkspaceChanged));
     },
 
+    _lookupCloneForMetaWindow: function (metaWindow) {
+        for (let i = 0; i < this._workspaces.length; i++) {
+            let clone = this._workspaces[i].lookupCloneForMetaWindow(metaWindow);
+            if (clone)
+                return clone;
+        }
+        return null;
+    },
+
+    // Should only be called from active overlay context
+    activateWindowFromOverlay: function (metaWindow, time) {
+        let global = Shell.Global.get();
+        let activeWorkspaceNum = global.screen.get_active_workspace_index();
+        let windowWorkspaceNum = metaWindow.get_workspace().index();
+
+        let clone = this._lookupCloneForMetaWindow (metaWindow);
+        clone.actor.raise_top();
+
+        if (windowWorkspaceNum != activeWorkspaceNum) {
+            let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
+            workspace.activate_with_focus(metaWindow, time);
+        } else {
+            metaWindow.activate(time);
+        }
+    },
+
     // Updates position of the workspaces display based on the new coordinates.
     // Preserves the old value for the coordinate, if the passed value is null.
     updatePosition : function(x, y) {